﻿using CID.Domain.Development;
using CID.Domain.Infrastructure;

namespace CID.Domain.Persistence.Mappings.Development
{
    public class VersionMap : DescribedEntityMap<Version>
    {
        public const string DependenciesMapTable = "VersionComponentDependencies";

        public VersionMap() : base()
        {
            References<Component>(x => x.Component);
            References<Release>(x => x.Release).Nullable();
            References<Package>(x => x.ActivePackage).Nullable().Cascade.None().ForeignKey("FK_Version_ActivePackage");
            HasOne<DeploymentDefinition>(x => x.DeploymentDefinition).Cascade.All().PropertyRef(x => x.Version);
            HasMany<Package>(x => x.Packages);
            HasManyToMany<Component>(x => x.DependsOn).Table(DependenciesMapTable);
        }
    }
}
